﻿using CslaHispano.EncapsulatedInvoke.Domain.Entities;
using CslaHispano.EncapsulatedInvoke.Domain.Repository;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Ninject;
using Csla;
using EncapsulateInvoke.EF;
using Moq;


namespace EncapsulatedInvoke.Test
{
    
    
    /// <summary>
    ///This is a test class for SystemEditTest and is intended
    ///to contain all SystemEditTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SystemEditTest
    {

        private TestContext testContextInstance;
        private IKernel _NInject;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestInitialize()]
        public void Addbind()
        {
            _NInject = new StandardKernel();
            _NInject.Bind<ISystemEditRepository>().To<SystemEditEF>();
        }


        /// <summary>
        ///A test for NewSystemEdit
        ///</summary>
        [TestMethod()]
        public void create_SystemEdit_test()
        {
            SystemEdit _system = SystemEdit.NewSystemEdit();
            Assert.IsTrue(_system.IsNew);
            Assert.IsTrue(_system.Modules.IsChild);           
        }

        /// <summary>
        ///A test for GetSystemEdit
        ///</summary>
        [TestMethod()]
        public void verifica_reglas_negocio()
        {
            var _SystemEdit = new Mock<SystemEdit>();
            _SystemEdit.SetupGet(p => p.Code).Returns("1");
            _SystemEdit.SetupGet(p => p.Description).Returns("System 1");
            Assert.AreEqual("System 1", _SystemEdit.Object.Description);

            //Evalua reglas de validación
            Assert.IsTrue(_SystemEdit.Object.IsValid);

        }

        [TestMethod]
        public void verifica_consulta_registro()
        {
            Csla.ApplicationContext.ClientContext["NInject"] = _NInject;
            SystemEdit _system = SystemEdit.GetSystemEdit("1");
            Assert.IsTrue(_system.Code == "");
        }
    }
}
